package com.example.epoxystudy.views;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PagerSnapHelper;
import android.support.v7.widget.SnapHelper;
import android.util.AttributeSet;
import android.view.ViewGroup;

import com.airbnb.epoxy.Carousel;
import com.airbnb.epoxy.ModelView;

@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_MATCH_HEIGHT)
public class PagerCarousel extends Carousel {
    public PagerCarousel(Context context) {
        super(context);
    }

    public PagerCarousel(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Nullable
    @Override
    protected SnapHelperFactory getSnapHelperFactory() {
        return new SnapHelperFactory() {
            @NonNull
            @Override
            public SnapHelper buildSnapHelper(Context context) {
                return new PagerSnapHelper();
            }
        };
    }

    @NonNull
    @Override
    protected LayoutManager createLayoutManager() {
        return new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false);
    }
}
